<template>
  <div class="videoPreview">
    <video-player
      ref="videoPlayer"
      :playsinline="true"
      :options="playerOptions"
    >
    </video-player>
  </div>
</template>
<script>
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
export default {
  name: 'videoPreview',
  props: {
    videourl: {
      type: String,
      required: true
    }
  },
  components: {
    videoPlayer
  },
  data() {
    return {
      playerOptions: {
        playbackRates: [0.5, 1.0, 1.5, 2.0], // 播放速度
        autoplay: false, // 如果是true 浏览器准备好时开始回放,
        muted: false,
        loop: false, // 导致视频一结束就重新开始
        preload: 'none',
        language: 'zh-CN',
        aspectRatio: '16:9',
        fluid: true,
        sources: [
          {
            type: 'video/mp4',
            src: this.videourl
          }
        ],
        notSupportedMessage: '此视频暂时无法播放,请稍后再试!',
        controlBar: {
          timeDivider: true,
          durationDisplay: true,
          remainingTimeDisplay: false,
          fullscreenToggle: true // 全屏按钮
        }
      }
    }
  },
  computed: {
    player() {
      return this.$refs.videoPlayer.player
    }
  },
  watch: {},
  methods: {},
  created() {},
  mounted() {}
}
</script>
<style lang="less" scoped>
.videoPreview {
  width: 800px;
  height: 450px;
  background-color: rgba(0, 0, 0, 0.3);
  text-align: center;
  line-height: 100px;
  border-radius: 4px;
  overflow: hidden;
}
</style>
